<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Truncates a large object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pg-lo-tell.html">« pg_lo_tell</a></li>
      <li style="float: right;"><a href="function.pg-lo-unlink.html">pg_lo_unlink »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pgsql.html">PostgreSQL 函数</a></li>
    <li>Truncates a large object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pg-lo-truncate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_lo_truncate</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.6.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_lo_truncate</span> &mdash; <span class="dc-title">
   Truncates a large object
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-lo-truncate-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_lo_truncate</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-lob.html" class="type PgSql\Lob">PgSql\Lob</a></span> <code class="parameter">$lob</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_lo_truncate()</strong></span> truncates an <span class="classname"><a href="class.pgsql-lob.html" class="classname">PgSql\Lob</a></span> instance.
  </p>
  <p class="para">
   To use the large object interface, it is necessary to
   enclose it within a transaction block.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-lo-truncate-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">lob</code></dt>

     <dd>

      <p class="para">通过 <span class="function"><a href="function.pg-lo-open.html" class="function">pg_lo_open()</a></span> 返回的 <span class="classname"><a href="class.pgsql-lob.html" class="classname">PgSql\Lob</a></span> 实例。</p>
     </dd>

    
    
     <dt>
<code class="parameter">size</code></dt>

     <dd>

      <p class="para">
       The number of bytes to truncate.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-lo-truncate-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-lo-truncate-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">lob</code> 接受 <span class="classname"><a href="class.pgsql-lob.html" class="classname">PgSql\Lob</a></span> 
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-lo-truncate-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1919">
    <p><strong>示例 #1 <span class="function"><strong>pg_lo_truncate()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;$doc_oid&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">189762345</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$database&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=jacarta"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"begin"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$handle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_lo_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$doc_oid</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Truncate&nbsp;to&nbsp;0<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_lo_truncate</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"commit"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div> 
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.pg-lo-truncate-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pg-lo-tell.html" class="function" rel="rdfs-seeAlso">pg_lo_tell()</a> - 返回大型对象的当前指针位置</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>